<template>
	<view>
		<cu-custom bgColor="bg-black" :isBack="true">
			<block slot="content">我的咨询</block>
		</cu-custom>
		<view class="cu-list menu-avatar" v-if="consultList.length!=0">
			<view class="cu-item" v-for="item in consultList" :key='item.id' @click="handNavChat(item)">
				<view v-if="userMsg.id==item.lawId" class="cu-avatar radius lg" :style="{backgroundImage:'url('+ item.userHandlUrl +')'}"></view>
				<view v-else class="cu-avatar radius lg" :style="{backgroundImage:'url('+ item.lawHandlUrl +')'}"></view>
				<view class="content">
					<view>
						<view v-if="userMsg.id==item.lawId" class="text-cut">{{item.userNickName}}</view>
						<view v-else class="text-cut">{{item.lawTrueName}}</view>
						<view class="cu-tag round bg-orange sm">{{item.isOpen==1?'进行中...':'已关闭'}}</view>
					</view>
					<view class="text-gray text-sm flex">
						<view class="text-cut">凯尔，你被自己的光芒变的盲目！</view>
					</view>
				</view>
				<view class="action">
					<view class="text-grey text-xs">22:20</view>
					<!-- <view class="cu-tag round bg-red sm">5</view> -->
				</view>
			</view>
		</view>
		<view style="text-align: center;" v-else>
			<image src="../../../static/img-no-data.png" style="width: 320upx;
		height: 320upx;margin: 200upx auto;" mode=""></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				consultList: [],
				userMsg: {}
			};
		},
		async onLoad() {
			if (uni.getStorageSync('USER')) {
				this.userMsg = JSON.parse(uni.getStorageSync('USER'))
			}

			console.log(this.userMsg)
			let res = await this.http.findChatRoom()
			this.consultList = res
			console.log(res, '咨询列表')
		},
		methods: {
			handNavChat(item) {
				console.log(item)
				let imgUrl = ''
				if (this.userMsg.id == item.lawId) {
					imgUrl = item.userHandlUrl
				} else {
					imgUrl = item.lawHandlUrl
				}
				uni.navigateTo({
					url: '/pages/chat/chat?item=' + JSON.stringify(item) + '&imgUrl=' + imgUrl
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
